package com.atguigu.ems.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.atguigu.ems.daos.BaseDao;
import com.atguigu.ems.entities.Employee;
import com.atguigu.ems.orm.Page;

public class BaseService<T> {

	@Autowired
	protected BaseDao<T> dao;
	
	public Employee get(Integer id){
		return dao.get(id);
	}
	
	@Transactional(readOnly=true)
	public Page<T> getPage(Page<T> page){
		return dao.getPage(page);
	}
	
	@Transactional
	public void save(T entity){
		dao.save(entity);
	}
	
	@Transactional(readOnly=true)
	public T getBy(String propertyName, Object propertyVal){
		return dao.getBy(propertyName, propertyVal);
	}
	
	@Transactional(readOnly=true)
	public List<T> getAll(boolean ... cached){
		return dao.getAll(cached);
	}
}
